package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.DailyLogs;
import com.dragon.repository.entity.OtherFile;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class DailyLogsVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "日报标题")
    private String dailyTitle;

    @ApiModelProperty(value = "今日总结")
    private String summary;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "是否删除0未删除1删除")
    private Integer deleted;

    @ApiModelProperty(value = "明天工作计划")
    private String workPlan;

    @ApiModelProperty(value = "待处理的问题")
    private String pendingIssues;

    @ApiModelProperty(value = "地址")
    private String address;

    @ApiModelProperty(value = "类型 1日报 2周报 3月报")
    private Integer type;

    @ApiModelProperty(value = "汇报人id")
    private Integer reporterId;

    @ApiModelProperty(value = "附件")
    List<OtherFile> otherFiles;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static DailyLogs convert(DailyLogsVO vo) {
        DailyLogs entity = new DailyLogs();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<DailyLogs> convertList(List<DailyLogsVO> list) {
        List<DailyLogs> resultList = new ArrayList<>();
        for (DailyLogsVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
